Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

      A  B  C  D  E  F  G  H  I  J  K  L  M
     N  O  P  Q  R  S  T  U  V  W  X  Y  Z

Index Column

Index

3 Phase Power

7-Segment Code
7-segment display - ladder logic

74XXX TTL Data Sheets

A


abampere

abbreviations:
     Electrical Engineering Abbreviations and Acronyms
     Military Abbreviations and Acronyms

ABCD matrices for transmission lines

Absolute Pressure

Absolute Viscosity

absorption spectra

acids - pH of common inorganic acids

activity series of metals

adder:
     full-adder
     half-adder

air composition

Air Pressure Loss For Every 100 Feet of Clean Commercial Steel Pipe

American National Standard Letter Designation for Welding and Allied Processes (ANSI/AWS A2.4-9I)

American Standard Code for Information Interchange (ASCII)

American Wire Gauge (AWG)

Ampacity of Copper and Aluminum Insulated Wire

ampere

Ampere's Circuital Law

amplifier - General purpose Amplifier

amplifier - general purpose inverting amplifier

angle between two vectors

Angular Speed Formula

Angular Velocity Formula

apparent power

area of two dimensional shapes

area unit conversion calculator

Atmospheric Pressure at Altitudes Above Sea Level

AutoCAD Notes

AutoDesk AutoCAD Notes

automation

AWG (American Wire Gage)



battery technology

beam:
     structural beams

Beam Deflection

Beam Design and Analysis for Moment and Shear

Belt:
     V-belt:
          Commercially available "5V" Sheave Pitch Diameter
          dimensions
          sizing chart
          Belt Reduced Power Capability with Contact Angle

Bernoulli's Law

bevel gear

Blot-Savart Law for Magnetic Field & Lorentz Force Equation

Bleeder Valve

blinking lamp circuit - ladder logic

bolt: Eccentrically Loaded Bolts

bolt and nut materials

bolt technical reference guide

Boltzmann constant

Bonding between atoms and molecules

boolean algebra summary

Boundary Conditions

Boyle's Law

BSPT (British Standard Pipe Thread)

BSPP (British Standard Parallel Pipe)

Bulk Modulus of Common Substances

Buoyancy Force

 

camera: contact lens camera

camera: vision system cameras

Capacitance, Conductance, and Inductance

Capacitor

capacitor energy storage

Cartesian Coordinate System

Cartesian, Cylindrical, Spherical Conversions

centroids of two dimensional shapes

Ceramics

chain pitch selection chart for roller chains

chain sprocket and platewheels

Charge Distributions

charge of an electron

charge of a proton

Charles's Law

Chebyshev Frequency Response for n=4

Check Valve

circle

circuit breaker

circuit components

co-function identities

codes:
     2 out of 5 code
     7-Segment Code
     ASCII
     Gray Codes

Coefficients of Friction

Coefficients of Linear Thermal Expansion

Column Design and Analysis

Combined Stresses, Axial, Bending, Shear: Mohr's Circle

comparator

Comparison of Properties of Straight Tungsten Carbides and Tool Steels

complex trigonometric identities

complex numbers

Complex Numbers and Phasor Techniques

compressor

Compton scattering

connectors

connectors - modular connectors

Connections: Bolted and Welded

contact configurations

contact lens camera

contactor

Continuity Equation in Fluid Mechanics

Continuity Equation in Electromagnetism

conversions (number base):
     binary to decimal conversion
     binary to hexadecimal conversion
     binary to octal conversion
     decimal to binary conversion
     decimal to hexadecimal conversion
     decimal to octal conversion
     hexadecimal to binary conversion
     hexadecimal to decimal conversion
     octal to binary conversion
     octal to decimal conversion

conversions between two-port network parameters

Coordinate Systems in Electromagnetism

copper tubing
     dimensions of type K copper tubing

Coulomb's Law

CREO Parametric

cross product

Crystal structures for common metals at room temperature

curl operator

cylinder (pneumatic or hydraulic)

Cylindrical Coordinate System

Cylindrical, Spherical, Cartesian Conversions


D Latch

Dalton's Law of partial pressure

Darcy's Formula

data sheets

DC and AC Circuits

de Broglie Theorem

decibel dB

Decimal Equivalent Chart

decoder - ladder logic

Deflection in Beams

demultiplexer

density unit conversion calculator

dielectric constants of selected materials

dielectric strengths of selected materials

Dielectrics as related to Displacement Flux Density

differential operators

Differential Unit Vector in Cartesian Coordinate System

Differential Unit Vector in Cylindrical Coordinate System

Differential Unit Vector in Spherical Coordinate System

Dimensions of Steel Pipe

Dimensions of Steel Valve and Steel Fittings

diode

diode - Light Emitting Diode (LED)

diode - Schmitt Trigger

diode: Voltage drop across a diode

Directional Valve

distance between point and line

distance between point and plane

Divergence

divergence operator

Divergence Theorem

double angle formulas

dot product

drill bit size conversions

Ductility of Selected Materials Measured as Percent Elongation

earth

Eccentrically Loaded Bolts

efficiency

elastic modulus for selected materials

elastomer: Hardness Scale comparison table of metals and elastomer

electric charge

electric current

Electric Field Intensity

Electric Stored Energy Density

Electrical Metallic Tubing - EMT Sizes, Weights, and Dimensions

Electromagnetic Spectrum

Elements of the Periodic Table

EMT Conduit Sizes, Weights, and Dimensions

encoder

energy storage in a capacitor

Energy Storage in Electric and Magnetic Fields

energy unit conversion calculator

equation of a plane

equations

Euler identity

even-odd identities

Exclusive OR (XOR) vs Exclusive NOR (XNOR)

expansion for hyperbolic functions

expansion for sine, cosine, tangent, cotangent

fans as applied to electrical enclosures

Faraday's Law

Faraday's Law and Ampere's Circuital Law in differential Form

fastener: Thread Series Designation

fastener technical reference guide

FDA:

21 CFR 211 - CURRENT GOOD MANUFACTURING PRACTICE FOR FINISHED PHARMACEUTICALS

FlexiBowl

flip-flop using Omron KEEP instruction

Flow Curve and Typical Values of Strength Coefficient K and Strain Hardening Exponent n for Selected Materials

Flow of Air Through Schedule 40 Steel Pipe

Flow of Water Through Schedule 40 Steel Pipe

Fluid Sealing Material Compatibility Chart

force unit conversion calculator

fractions to decimal conversion table

Frequency Allocation Chart in the US (pdf)

full-adder - ladder logic

Gauss' Law

Gauss' Law derived from Conservation of Charge and Ampere's Law

GD&T (Geometric Dimensioning and Tolerancing)

gear:
     bevel gear
     Gear Types

General Energy Equation (Fluid Mechanics)

Geneva drive

geometric tolerancing

Geometry

golden ratio

golden rectangle

Gradient in Cartesian, Cylindrical and Spherical Coordinates

gradient operator

Gray Code:
     Gray Codes
     how to generate gray codes

Greek alphabet

grippers

parallel grippers

needle grippers (overview)

H Beams & Wide Flange ASTM-A36/A572

H-Bridge

Hagen Poiseuille Law for Laminar Flow

half angle formulas

half-adder - ladder logic

Hamming Codes

Hand Pump System

Hardness Scale comparison table of metals and elastometers

Hazen-Williams Constants for Various Materials

head, Velocity

hexagon

HMI (Human Machine Interface)

hydraulic Horsepower

hydraulic Radius

hydraulic schematic symbols

hyperbolic functions

I Beams ASTM-A36/A572

identities:
     co-function identities
     complex trigonometric identities
     euler identity
     even-odd identities
     Pythagorean identities
     quotient identities
     reciprocal identities
     trigonometric identities
     vector identities

image parameters for T and pi networks

inductor

Inequalities

Infrared Spectrum

insulation: Relationship between an Insulator's K-factor, C-factor, and R-factor

integral tables

intensity of a sound wave

interlock circuit in Ladder Logic

Internal Fluid Pressure (psi) on Tubing

inverter

JK Flip Flop

Junior Beams ASTM-A36

Jupiter

kinematic equations

Kinematic Viscosity

Kirchhoff's Current Law

Ladder Logic Circuits

laminar flow: Hagen Poiseuille Law for Laminar Flow

Laplace Transforms

Laplace's Equation

Laplacian operators

Laplacian of a Scalar Function and a Vector

Latches

Law of Conservation of Charge

Law of cosines

length unit conversion calculator

Lens Types

Lenz's Law

Light Emitting Diode (LED)

Limits - Calculus

List of Natural Elements of the Periodic Table

logarithmic constant

logic functions - ladder logic

logic gates

Lorentz Force Equation

low-pass RC filter

Magnetic Field--Ampere's Law, Biot-Savart Law

Magnetic Field Intensity

Magnetic Flux Density

magnetic force on a moving charge

Magnetic Stored Energy Density

Magnetic Vector Potential

mass/weight unit conversion calculator

mathematical symbols

matrices

Maxwell's equations

mechanical power

Mechanics

mechanisms

Melting Points for Some Common Metals and Alloys

mesh sizes: Strainer Mesh Sizes and Size of Solids Removed When Strainer is Clean

Metals

metals: Hardness Scale comparison table of metals and elastometers

Mesh Size Chart

Microwave Oven (pdf)

millimeters to decimal conversion table

modular connectors

Modulus of elasticity for selected materials

modulus of rigidity

moment of inertia

moment of inertia transfer formula

momentum

Moody Friction Factor Chart

MOSFET:
     N-Channel MOSFET

Motion Control Using Servo and Stepper Motors

Motorola microcontrollers

motors:
     electric motor family tree
     classification of Motors by application
     NEMA classification of Motors
     PWM - pulse width modulation
     Sizing a Motor for Hydraulic Pump
     Standard Electric Motor Sizes
     DC Motor - Compound Wound

multiplexer

Multiplication Table (1 thru 12)

 

NAND (Diode-Transistor Logic)

needle grippers (overview)

NEMA Enclosure Ratings

NEMA Motor Frame Sizes

Neutralization Number

Newton's laws of motion

network functions: Types of Network Functions

NOR (Diode-Transistor Logic)

NPN Transistor

NPT (National Pipe Thread)

NPS (Nominal Pipe Size) - Straight pipe sizes

nut:
     bolt and nut materials

Ohm's Law

OSHA - Safeguarding Equipment and Protecting Employees from Amputations

PanelView: How to connect to PC

parameters:
     image parameters for T and pi networks

Pascal's Law

Permeability of a vacuum (or free space)

pi networks: image parameters for T and pi networks

pipe: dimensions and properties of schedule 40 and 80

Pipe Fitting Dimensions

pipe thread types

periodic table: List of Natural Elements of the Periodic Table

PLA

Plank's Law

plastics

PLC (Programmable Logic Controller)

PNP transistor

Poisson's Equation

Poisson's ratio

polar moment of inertia

Polarization

polygon

polymers

Potential Function for Static and Non Static Fields

power consumed by a resistor

Power developed by the product of the force and velocity

power definition

power - Mechanical Power

power-reducing/half angle formulas

power series representation

power:
     electrical apparent power

power transmitted by a shaft given a torque and speed of a shaft

power unit conversion calculator

powers of two

pressure (psi) conversion factors

Principle of Reciprocity

pressure: Atmospheric Pressure at Altitudes Above Sea Level

pressure: Internal Fluid Pressure (psi) on Tubing

product-to-sum formulas

proximity sensor - inductive

PTC CREO Parametric Notes

pump system: Hand Pump System

PWM (pulse width modulation)

Pythagoras' Theorem

Pythagorean identities

Pythagorean Triples

 

quadratic formula and proof

quotient identities

radius of gyration

range equation

radian measure

RC Time Delay

reciprocal identities

regeneration circuit

Relationship between Shear stress and Tensile stress

relay

relief valve

resistivity

Reynold's Equation

robots - Types of Industrial Robots

Rockwell Hardness Scales

ROM (Read Only Memory)

rubbers

safety - machine safety

safety - standards for machine safety

Sanitary Fittings - Tri-Clamp

Saybolt Universal Viscosity

scalar product of two vectors

Schedule 40 pipe: Working Pressure In PSI (psi) in Standard Pipe, Extra Heavy Pipe, Double Extra Heavy Pipe

Schmitt Trigger Diode

Schrödinger's equation

Scissor Lift Mechanism

screw materials

screw tapping and clearance chart

screw thread pitch

screw thread series designations

screw thread types

seals: Fluid Sealing Material Compatibility Chart

sensors

seal in contact in Ladder Logic

Shear and Moment Diagrams by the Summation of Areas

shear strain

Shear Strength of Materials

shear stress analysis on a bolt in single shear

shear stress: Relationship between Shear stress and Tensile stress

sheetmetal gauge sizes and weight/ft^2

SI prefixes

Sieve Opening Size Chart

Sizing a Motor Horsepower (HP) for Drilling, Tapping, and Threading

Sizing a Motor horsepower (HP) for Hydraulic Pumps

Sizing a motors horsepower (Hp) and torque for turning a solid round disk

Skin Depth of Copper

Slider-Crank connecting rod angular speed and acceleration

software notes

solar system

spacecrafts

spark plug

Specific Gravity

specific gravity of gases

specific gravity of liquids

Specific Roughness and Hazen-Williams Constants for Various Materials

Specific Weight

Spectrum: Electromagnetic Spectrum

Spectrum: Infrared Spectrum

speed of sound

speed unit conversion calculator

Spherical Coordinate System

Spherical, Cylindrical, Cartesian Conversions

sprockets and platewheel types

SR Latch

SR Master-Slave Flip-Flop

Stainless Steel Chemical Composition

Standard Electric Motor Sizes

standards for machine safety

Stefan-Boltzmann Law

Stepper Motor Wiring Diagrams

Stokes' Theorem

straight pipe sizes - NPS

strain hardening exponent: Flow Curve and Typical Values of Strength Coefficient K and Strain Hardening Exponent n for Selected Materials

Strainer Mesh Sizes and Size of Solids Removed When Strainer is Clean

strength coefficient: Flow Curve and Typical Values of Strength Coefficient K and Strain Hardening Exponent n for Selected Materials

Strength of Materials

Stress-Strain Curves (pdf)

Stress Summary

Stresses in Beams and Built up Sections and Bolt Spacing

Structural Members

summing junction amplifier

sum or difference of two angles

sum-to-product formulas

sun

sun spot

symbols - electrical symbols

symbols - mathematical symbols

synchronous belt

T networks:
     image parameters for T and pi networks

Tangent Line Problem

tap drill reference

temperature unit conversion calculator

tensile strength: Yield Strength and Tensile Strength for Selected Metals

thermal conductivities of various media

thermal expansion

thermal expansion: Coefficients of Linear Thermal Expansion

Thread Series Designations

thread types - screw

thread types: pipe thread types

time delay - RC Time Delay

timing belt

toggle output with a single pushbutton - ladder logic

toggle output using single pushbutton with different TON and TOFF delays - Ladder Logic

Tonnage for Hole Punching

tool steel:
     Comparison of Properties of Straight Tungsten Carbides and Tool Steels

tool steels

Torricelli's Theorem

Torque Couplings

torque unit conversion calculator

torsion

torsional deflection of a shaft

transformer

transistor - NPN

transistor - PNP

Transmission Line - Parallel Plate

transmission line table of equations(pdf)

Transmission Line Terminated by Resistive Load

Transmission Line with Discontinuity

Tri-Clamp Sanitary Fittings

triangle

trigonometric functions

trigonometric identities

trigonometric values for common angles

Triple Scalar Product

tubing: Dimensions of Type K Copper Tubing

tungsten carbide:
     Comparison of Properties of Straight Tungsten Carbides and Tool Steels

Two-Phase Alternating Current

Two-Port Network Conversions

Types of Network Functions

unit circle

Unit Vectors: Cylindrical & Cartesian, Spherical & Cartesian

USB - Universal Serial Bus

V-belt: Commercially available "5V" Sheave Pitch Diameter V-Belts

V-belt dimensions

V-belt sizing chart

V-Belt Reduced Power Capability with Contact Angle

valve: Bleeder Valve
valve: Check Valve
valve: Directional Valve
valve: Relief Valve

vector:
     angle between two vectors
     vector cross product
     scalar product of two vectors
     vector identities

viscosity

viscosity Index

vision cameras

vision systems

voltage

voltage - worldwide voltages

voltage divider

Voltage drop across a diode

voltage follower

voltage peak detector

voltage regulator

volume unit conversion calculator

wedge physics

weight/mass unit conversion calculator

Welding Filler Metals For Various Aluminum Alloys

welding processes

welding symbol: Location of Elements of a Welding Symbol

Wide Flange & H Beams ASTM-A36/A572

Wien's Law

Wire:
     American Wire Gauge (AWG)
     Ampacity of Copper and Aluminum Insulated Wire

Working Pressure In PSI (psi) in Standard Pipe, Extra Heavy Pipe, Double Extra Heavy Pipe

worldwide voltages

Exclusive OR (XOR) vs Exclusive NOR (XNOR)

Yield Strength and Tensile Strength for Selected Metals

Young's modulus of elasticity


 
 
 

MySQL Notes

 

how to insert image file into MySQL database using PHP

 

To bring up phpMyAdmin type the following address in your browser:

http://localhost/phpMyAdmin/

 

Integer Values

TINYINT Signed: -128 to 127. Unsigned: 0 to 255

SMALLINT Signed: -32768 to 32767. Unsigned: 0 to 65535

MEDIUMINT Signed: -8388608 to 8388607. Unsigned: 0 to 16777215

INT Signed: -2147483648 to 2147483647. Unsigned: 0 to 4294967295

BIGINT Signed: -9223372036854775808. Unsigned: 0 to 18446744073709551615

 

 

Text Types

The length for the text types can be quite confusing. The MySQL manual says this about the various lengths that each text type can hold:

TINYTEXT L+1 byte, where L < 2^8 
TEXT L+2 bytes, where L < 2^16
MEDIUMTEXT L+3 bytes, where L < 2^24
LONGTEXT L+4 bytes, where L < 2^32

This in not terribly helpful for beginners! So what does it mean. Well, the L + 1 part means, "The length of the string, plus 1 byte to store the value." The translated values for each are approximately:

TINYTEXT 256 bytes
TEXT 64 KiloBytes
MEDIUMTEXT 16 MegaBytes
LONGTEXT 4 GigaBytes

To confuse the issue even more, you can also use CHAR and VARCHAR to store your text. These are quite useful, if you know how many characters you want to store. For example, for a UK postcode you don't need more than 9 characters, and one of those will be a blank space. So there's no sense in setting a postcode field to hold 4 gigabytes! Instead, use CHAR or VARCHAR.

 

CHAR

You specify how many characters you want the field to hold. The maximum value is 255. For example:

CHAR(10)

This field can then hold a maximum of ten characters. But if you only use 4 of them, the rest of the 10 characters will be blank spaces. The blank spaces get added to the right of your text:

"TEXT         "

"TENLETTERS"

 

 

VARCHAR

Like CHAR, but the rest of the characters are not padded with blank spaces. The maximum value before MySQL 5.0.3 was 255. After this it's jumped to 65, 535. With VARCHAR, there is also an extra byte that records how long your text is.

 

 

 

Open and Close MySQL database:

inbuilt functions

mysql_connect()
mysql_select_db()
mysql_close()

The approach we'll take has three steps:

  1. Open a connection to MySQL itself
  2. Specify the database we want to open
  3. Close the connection

 

Step 1 - Open a connection to MySQL

The first job is to actually connect to MySQL. As it's name suggests, mysql_connect( ) does exactly that. Here's the code we're going to be using. But this is just to get your started. It is recommended that you don't dash off and use this on the internet! This is for learning purposes only.

<?PHP

$user_name = "root";
$password = "";
$database = "addressbook";
$server = "127.0.0.1";

mysql_connect($server, $user_name, $password);

print "Connection to the Server opened";

?>

Save your work and try it out on your server (this assumes that you have the Address Book database we created earlier, and that it is in the data folder of MySQL. If you don't, you can download all the files here.).

The first four lines are just setting up variables, and putting something in them:

$user_name = "root";
$password = "";
$database = "addressbook";
$server = "127.0.0.1";

The username we're trying here is "root" and the password is blank. These are the MySQL defaults. You don't need to change these, in most cases.

Hopefully, you won't have any errors. But the line that connects to MySQL is this:

mysql_connect($server, $user_name, $password);

So you type the name of the function first ( mysql_connect ), followed by the round brackets. In between the round brackets, you need three things: the name of your server, your MySQL username, and your MySQL password. These can be entered directly, like this:

mysql_connect( '127.0.0.1', 'root', '' );

Or as variables, like we did at first:

$user_name = "root";
$password = "";
$server = "127.0.0.1";

mysql_connect($server, $user_name, $password);

And that's all you need to get you connected to MySQL. But we haven't connected to the database yet. That's Step 2 on our list.

[http://www.homeandlearn.co.uk/php/php13p1.html]

 

Step 2 - Specify the database you want to open

In our code, we set up a variable with the name of our database:

$database = "addressbook";

We now need to do something with this variable. So add this new line to your code (the new line is in blue text):

$user_name = "root";
$password = "";
$database = "addressbook";
$server = "127.0.0.1";

mysql_connect($server, $user_name, $password);

$db_found = mysql_select_db($database);

print "Connection to the Server opened";

You use the mysql_select_db( ) function to specify which database you want to open. The function then returns a true/false value. If it finds your database, a value of true is returned; if your database can't be found then a value of false is returned. You can use some logic to test if the database was found. Change the last two lines of your code to this:

$db_found = mysql_select_db($database);

if ($db_found) {

print "Database Found";

}
else {

print "Database NOT Found";

}

Now change the database name from this:

$database = "addressbook";

to something like this:

$database = "addressbook2";

Run your code again, and you should see Database NOT Found printed out (unless you have a database called addressbook2). Change the database name back to addressbook.

But there's another option you can use for mysql_select_db - something called a resource link identifier. It's just a file handle that you used in an earlier section (opening text files). You use it like this:

$user_name = "root";
$password = "";
$database = "addressbook";
$server = "127.0.0.1";

$db_handle = mysql_connect($server, $user_name, $password);

$db_found = mysql_select_db($database, $db_handle);

if ($db_found) {

print "Database Found " . $db_handle;

}
else {

print "Database NOT Found " . $db_handle;

}

So when we connect to the database, we're now using this:

$db_handle = mysql_connect($server, $user_name, $password);

It's just the same as before, except we're returning a value from the mysql_connect function, and putting it into a variable called $db_handle. When we connect to the database, we can use this file handle:

$db_found = mysql_select_db($database, $db_handle);

The resource link identifier (file handle) goes after the name of the database you want to open. You can then use this file handle to refer to your database connection.

Now that we've connected to MySQL, and connected to a database, it's time to close the connection.

 

[http://www.homeandlearn.co.uk/php/php13p1.html]

 

 

Step 3 - Close the connection

Closing a connection to a database is quite easy. If you've used a file handle, as above, you just do this:

mysql_close( $db_handle );

Otherwise, you don't need to bother. It's recommended that you take the file handle approach, though. That's what we'll be doing from now on.

So, we'll add a line to close our connection. Here what your code should now look like:

<?PHP

$user_name = "root";
$password = "";
$database = "addressbook";
$server = "127.0.0.1";

$db_handle = mysql_connect($server, $user_name, $password);

$db_found = mysql_select_db($database, $db_handle);

if ($db_found) {

print "Database Found ";
mysql_close($db_handle);

}
else {

print "Database NOT Found ";

}

?>

http://www.homeandlearn.co.uk/php/php13p1.html

 

 

 

 

 

 

 

 

Structured Query Language

SQL (pronounced SEEKwel), is a way to query and manipulate databases. The basics are quite easy to learn. If you want to grab all of the records from a table in a database, you use theSELECT word. Like this:

SELECT * FROM Table_Name

SQL is not case sensitive, so the above line could be written:

Select * From Table_Name

But your SQL statements are easier to read if you type the keywords in uppercase letters. The keywords in the lines above are SELECT and FROM. The asterisk (*) means "All Records".Table_Name is the name of a table in your database. So the whole line reads:

"SELECT all the records FROM the table called Table_Name"

http://www.homeandlearn.co.uk/php/php13p2.html


You can see how many rows were returned from the database table.

we attempt to connect to the database:

$user_name = "root";
$pass_word = "";
$database = "login";
$server = "127.0.0.1";

$db_handle = mysql_connect($server, $user_name, $pass_word);
$db_found = mysql_select_db($database, $db_handle);

if ($db_found) {

}
else {

$errorMessage = "Error logging on";

 

 

The inbuilt function mysql_num_rows( ) is used for this. If no rows were returned, then that tells you that there's something wrong with either the username or password.

$num_rows = mysql_num_rows($result);

Next, we test the $num_rows variable to see if it's greater than zero. If it is, then you have a successful logon. If not, then it's invalid:

if ($num_rows > 0) {

$errorMessage= "logged on ";

}
else {

$errorMessage= "Invalid Logon";

}

if ($db_found) {

}
else {

$errorMessage = "Error logging on";

}

If the database isn't found, then some text is added to the error message variable. If the database was found, strip the incoming text of any unwanted characters (SQL Injection attacks). These next two lines call the function at the top of the code:

$uname = quote_smart($uname, $db_handle);
$pword = quote_smart($pword, $db_handle);

With the username and password sanitised, we can then set up a SQL command. We're selecting all the records in the database where the incoming username and password match the database table fields called L1 and L2:

$SQL = "SELECT * FROM login WHERE L1 = $uname AND L2 = $pword";

Next, issue the SQL command using mysql_query( ):

$result = mysql_query($SQL);

We need to check what is returned by the mysql_query() function. The value in $result will either be true (if any records are returned) or false (if none are returned). We're checking to see if there were any errors when the SQL command was issued against the database table. If so, put something in the error message variable:

if ($result) {

}
else {

$errorMessage = "Error logging on";

}

If the SQL command was issued successfully, you can see how many rows were returned from the database table. The inbuilt function mysql_num_rows( ) is used for this. If no rows were returned, then that tells you that there's something wrong with either the username or password.

$num_rows = mysql_num_rows($result);

Next, we test the $num_rows variable to see if it's greater than zero. If it is, then you have a successful logon. If not, then it's invalid:

if ($num_rows > 0) {

$errorMessage= "logged on ";

}
else {

$errorMessage= "Invalid Logon";

}

In the above code, the number of rows returned could be greater than 1. That would mean that 2 or more people have the same username and password. If you have a website where each user has to be unique, then you obviously want to check if $num_rows = 1. For some websites, it doesn't really matter if 2 or more people have the same login details. But for things like forums, where people are posting and replying to the input of others, then it does matter. After all, you want to credit forum users with the correct posts. For the purpose of this tutorial, assume that it doesn't matter if login details are the same.


Sessions:

<?PHP

session_start();

if (!(isset($_SESSION['login']) && $_SESSION['login'] != '')) {

header ("Location: login.php");

}

?>

This checks to see if the session called login is set, and that it's not a blank string. If it is, then the user is redirected to the login page. In the script, you first start the session:

session_start();

Next comes a complex If statement:

if () {

header ("Location: login.php");

}

In between the round brackets of the If statement, we have the NOT operator. This is followed by the inbuilt isset() function:

if ( !(isset( ) ) {

}

This says, "If NOT isset". Or, "if the value of the isset function is false ... " If the value in the round brackets of isset is indeed false, then the code between the curly brackets { } gets executed. That code, for us, was the redirection line. What we have between the round brackets of isset is this:

($_SESSION['login'])

That's just our session variable from the login page. Is the user has logged in successfully, a value of 1 will be set inside of this variable.

But we also need to check the session variable for a blank string. So we have and AND part to the statement:

&& $_SESSION['login'] != ''

This says, "AND session login DOES NOT EQUAL a blank string". In other words, we check to see if a session variable has been set, and that it's not a blank string.

If everything is OK then the user will see the HTML code below the PHP at the top. If it's not, you can send them somewhere else. But you need to put that PHP code at the top of every page that you want to protect. And it needs to go before any HTML code. You can't put it in the head section, otherwise you'll get "header" errors.

http://www.homeandlearn.co.uk/php/php14p3.html


 

echo

  • Outputs one or more strings separated by commas
  • No return value

    e.g. echo "String 1", "String 2"

print

  • Outputs only a single string
  • Returns 1, so it can be used in an expression

    e.g. print "Hello"

    or, if ($expr && print "foo")

print_r()

  • Outputs a human-readable representation of any one value
  • Accepts not just strings but other types including arrays and objects, formatting them to be readable
  • Useful when debugging
  • May return its output as a return value (instead of echoing) if the second optional argument is given

var_dump()

  • Outputs a human-readable representation of one or more values separated by commas
  • Accepts not just strings but other types including arrays and objects, formatting them to be readable
  • Uses a different output format to print_r(), for example it also prints the type of values
  • Useful when debugging
  • No return value

var_export()

  • Outputs a human-readable and PHP-executable representation of any one value
  • Accepts not just strings but other types including arrays and objects, formatting them to be readable
  • Uses a different output format to both print_r() and var_dump() - resulting output is valid PHP code!
  • Useful when debugging
  • May return its output as a return value (instead of echoing) if the second optional argument is given

Notes:

  • Even though print can be used in an expression, I recommend people avoid doing so, because it is bad for code readability (and because it's unlikely to ever be useful). The precedence rules when it interacts with other operators can also be confusing. Because of this, I personally don't ever have a reason to use it over echo.
  • Whereas echo and print are language constructs, print_r() and var_dump()/var_export() are regular functions. You don't need parentheses to enclose the arguments to echo or print (and if you do use them, they'll be treated as they would in an expression).

http://stackoverflow.com/questions/1647322/whats-the-difference-between-echo-print-and-print-r-in-php


Which MySQL datatype use for store an IP address?

If you want to store IP address in mysql database then don’t mistake to use varchar datatype because you can use INT UNSIGNED 4(BYTE) datatype. using integer datatype you can save more space in database.

when you fire insert query at that time use INET_ATON() and select query at that time INET_NTOA() use. how to use this function given bellow example.

Create Table :

CREATE TABLE IF NOT EXISTS `ip_addresses` (

`id` int(10) unsigned NOT NULL AUTO_INCREMENT,

`ip_address` INT(4) UNSIGNED NOT NULL,

PRIMARY KEY (`id`)

);

Insert Data :

INSERT INTO `ip_addresses` (`ip_address`) VALUES (INET_ATON("127.0.0.1"));

Select Data :

SELECT id, INET_NTOA(`ip_address`) as ip FROM `ip_addresses`;

Try this, this is a very simple.......

http://itsolutionstuff.com/post/which-mysql-datatype-use-for-store-an-ip-address


 

Retrieving Data From More Than One Table

 

 

 
 

©2024 tigerquesttech.com